#!/bin/sh

#first mkdir test in server and client ,chmod -R 777 test

read -p "input source directory:" sdir
read -p "input destination directory:" ddir

dir=/data/www/test
dirid=/data/home/app100683143

alone (){
        read -p "input client ip:" ip
	/usr/bin/rsync -avz --delete $dir/$sdir/ $ip:$dir/$ddir
	ssh -p36000 $ip "sudo /bin/su - root '$dirid/client.sh'"
}

all (){
        for i in `cat ip.txt`

        do
                /usr/bin/rsync  -avz --delete $dir/$sdir/  $i:$dir/$ddir
		ssh -p36000 $i "sudo /bin/su - root '$dirid/client.sh'"
        done
}

case $1 in
        alone)
        alone
        ;;
        all)
        all
        ;; 
        *)
        exit 1
esac



